<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>13题，计算天数</title>
</head>
<body>
    <p>
        如果今天是周二，那么1000天后是<i id="weeks"></i>
    </p>
    <p>
        点击输入按钮，输入一个天数
        <input type="button" value="输入" onclick="days()">
    </p>
    <script>
        var weeksArr = ['日','一','二','三','四','五','六'];
        function days(flag) {
            var day_num = prompt(flag ? '请输入正确的天数' : '请输入一个天数');
            if (!/^[0-9]*$/i.test(day_num)) {
                days(true);
                return;
            }
            
            let weeks = (parseInt(day_num) % 7 + 2) % 7;
            alert(`${day_num}天后是星期${weeksArr[weeks]}`);
        }

        function caculateDay() {
            let weeks = document.getElementById('weeks');
            
            weeks.innerHTML = `星期${weeksArr[(1000 % 7 + 2) % 7]}`;
        }
        caculateDay();
    </script>
</body>
</html>